package cn.slipi.admin.common.response.vo;

import com.github.pagehelper.PageInfo;

import java.util.List;

/**
 * 分页VO
 *
 * @author lee
 */
public class PageVo<V> {

    private long total;
    private long pageNo;
    private long pageSize;
    private long pageTotal;
    private List<V> list;

    public PageVo(long pageNo, long pageSize, long total, List<V> list) {
        this.pageNo = pageNo;
        this.pageSize = pageSize;
        this.total = total;
        this.list = list;
        this.pageTotal = total / pageSize;
    }

    public PageVo(long pageNo, long pageSize, long pageTotal, long total, List<V> list) {
        this.pageNo = pageNo;
        this.pageSize = pageSize;
        this.pageTotal = pageTotal;
        this.total = total;
        this.list = list;
    }

    public PageVo(PageInfo<?> pageInfo, List<V> list) {
        this.pageNo = pageInfo.getPageNum();
        this.pageSize = pageInfo.getPageSize();
        this.pageTotal = pageInfo.getPages();
        this.total = pageInfo.getTotal();
        this.list = list;
    }

    public static <V> PageVo<V> of(PageInfo<?> pageInfo, List<V> list) {
        return new PageVo<V>(pageInfo, list);
    }

    public final long getTotal() {
        return total;
    }

    public final List<V> getList() {
        return list;
    }

    public long getPageNo() {
        return pageNo;
    }

    public long getPageSize() {
        return pageSize;
    }

    public long getPageTotal() {
        return pageTotal;
    }

    public void setPageNo(long pageNo) {
        this.pageNo = pageNo;
    }

    public void setPageSize(long pageSize) {
        this.pageSize = pageSize;
    }

    public void setPageTotal(long pageTotal) {
        this.pageTotal = pageTotal;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public void setList(List<V> list) {
        this.list = list;
    }
}
